<?php
session_start(); 
include_once "config.php";
include_once "connect.php";
include_once "sujet.php";
		
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>AP3-SP-les phoques du desert</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="verification.js"></script>	
</head>
<body onLoad="display_c()">
	<script src="jquery.js"></script>
	<div id="all">
		<div id="header">		
		<?php		
		$log=0;
		if(isset($_SESSION["user"]))
		{
			$log=1;
		}
			$titre=mysql_query("select libelle_rubrique from AP3_SP_rubrique where id_rubrique='".$_GET["id"]."'");
		while($t=mysql_fetch_assoc($titre))		{
		
		echo "<h1>".$t["libelle_rubrique"]."</h1><br/>";
		echo "<a href='index.php'>Accueil</a> > ";
		echo "<a href='categorie.php?id=".$_GET["id"]."'>".$t["libelle_rubrique"] ."</a> > ";
		}
		?>
		</div>
		
		<div id="content">
		
		<?php
			$post=mysql_query("SELECT * from AP3_SP_post as P	
			join AP3_SP_rubrique as R ON P.id_rubrique=R.id_rubrique
			join AP3_SP_categorie as C ON R.id_categorie=C.id_categorie
			WHERE R.id_rubrique='".$_GET["id"]."' AND P.id_pere='0' ");
			if($log==1)
			{
				$post2=mysql_query("select id_type from AP3_SP_user where pseudo=\"".$_SESSION["user"]."\"") or die(mysql_error());
				$p2=mysql_fetch_assoc($post2);
				foreach($p2 as $res)
				{	
				}
			
			
			//bouton pour ajouter un nouveau post
			echo "<form name='redirect' action='formulairepost.php?id=".$_GET["id"]."&id_user=".$_SESSION["user"] ."' method='post'>";
			echo "<input type='submit' name='ajouterpost' value='Ajouter'/>";
			}
			
			
			while($p=mysql_fetch_assoc($post))		
		{
			echo"</form>";
			echo"<strong>";
			echo "<a href='affiche_post.php?id_post=".$p["id_post"]."&id_categorie=".$_GET["id"]."'>".$p["titre"]."</a>";
			echo"</strong><br/>";
			if($log==1)
			{
				if($p["pseudo"]==$_SESSION["user"] || 3==$res)
					{
						echo "<dd><a href='delete.php?id_post=".$p["id_post"]."&id_categorie=".$_GET["id"]."'>SupprimerPost</a></dd>"; //lien supprime post
						echo "<dd><a href='modifierpost.php?id_post=".$p["id_post"]."'>modifier</a><br/></dd>"; //lien modifier post
					}
			}
		}
		?>
		</div>
		
		<div id="footer">
			<div id="ct">
			
			</div>
			
			<div id="droit">
			<marquee>
			Made by Les Phoques Du Désert
					</marquee>
			</div>
		</div>
	</div>
</body>
</html>